package design_pattern.singleton;

/**
 * @Author pc
 * @Date 2019/8/22 17:40
 * @Description 饿汉单例模式，直接初始化
 */
public class HungerSingleton {
    private static HungerSingleton instance = new HungerSingleton();//直接初始化，线程安全

    /**
     * 私有构造器，保证外部无法初始化，反射除外
     */
    private HungerSingleton(){}

    /**
     * 外部调用，返回单例对象
     * @return
     */
    public static HungerSingleton getInstance(){
        return instance;
    }
}
